function init() {
    document.getElementById("upload").addEventListener("change", getFileName);
}

function getFileName(theEvt) {
    var file = theEvt.target.files[0];
    var reader = new FileReader();
    reader.onload = function (evt) {
        var result = evt.target.result;
        var dataset;
        var Json;
       switch(file.name.split('.').pop()){
           case 'csv':
               Json = CSV2JSON(result);
               dataset = JSON.parse(Json);
               break;
           case 'json':
               Json = result;
               dataset = JSON.parse(Json);
               break;
           case 'tsv':
               Json = tsvJSON(result);
               dataset = JSON.parse(Json);
           break;
           default :
               alert("this extension not supported");
       }
    };
    reader.readAsText(file);
}
